package com.bite.system.Controller;

import com.bite.system.DTO.ExamAddDTO;
import com.bite.system.DTO.ExamDTO;
import com.bite.system.DTO.ExamEditDTO;
import com.bite.system.DTO.ExamQuestionDTO;
import com.bite.system.Service.ExamService;
import com.bite.system.VO.ExamDetailVO;
import domain.R;
import domain.TableDataInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * 竞赛管理
 */
@RestController
@RequestMapping("/exam")

public class ExamController {

    @Autowired
    private ExamService examService;

    /**
     * 查询竞赛列表
     * @param examDTO
     * @return
     */
    @GetMapping("/list")
    public TableDataInfo list(ExamDTO examDTO){
        return examService.list(examDTO);
    }


    /**
     * 添加竞赛
     * @param examAddDTO
     * @return
     */
    @PostMapping("/add")
    public R<String> add(@RequestBody ExamAddDTO examAddDTO){
        return examService.add(examAddDTO);
    }

    /**
     * 添加竞赛题目
     * @param examQuestionDTO
     * @return
     */
    @PostMapping("/addQuestion")
    public R<Void> addQuestion(@RequestBody ExamQuestionDTO examQuestionDTO){
        return examService.addQuestion(examQuestionDTO);
    }

    /**
     * 获取竞赛详情
     * @param examId
     * @return
     */
    @GetMapping("/detail")
    public R<ExamDetailVO> detail(Long examId){
        return examService.detail(examId);
    }

    /**
     * 编辑基本竞赛信息
     * @param examEditDTO
     * @return
     */
    @PutMapping("/edit")
    public R<Void> edit(@RequestBody ExamEditDTO examEditDTO){
        return examService.edit(examEditDTO);
    }


    /**
     * 删除竞赛题目
     * @param examId
     * @param questionId
     * @return
     */
    @DeleteMapping("/delete")
    public R<Void> delete(Long examId,Long questionId){
        return examService.delete(examId,questionId);
    }

    /**
     * 删除竞赛
     * @param examId
     * @return
     */
    @DeleteMapping("/deleteExamQuestion")
    public R<Void> deleteExamQuestion(Long examId){
        return examService.deleteExamQuestion(examId);
    }


    /**
     * 发布竞赛
     * @param examId
     * @return
     */
    @PutMapping("/publish")
    public R<Void> publish(Long examId){
        return examService.publish(examId);
    }

    /**
     * 撤销发布竞赛
     * @param examId
     * @return
     */
    @PutMapping("/quash")
    public R<Void> quash(Long examId){
        return examService.quash(examId);
    }




}
